package com.jiezheng.huinong.util;

import java.io.IOException;
import java.io.Reader;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

public class DbUtil {
	private static SqlSessionFactory sqlSessionFactory = null;  
    static{  
        String resource = "mybatis-config.xml";  
        Reader reader = null;  
        try {  
            reader = Resources.getResourceAsReader(resource);  
        } catch (IOException e) {  
            e.printStackTrace();  
            System.out.println("mybatis-config init failed!");
        }  
        sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);  
    }  
    public static SqlSessionFactory getSqlSessionFactory(){  
        return sqlSessionFactory;  
    }  
}
